package com.example.easyevent.fetcher;

import com.example.easyevent.type.User;
import com.example.easyevent.type.UserInput;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsMutation;
import com.netflix.graphql.dgs.DgsQuery;
import com.netflix.graphql.dgs.InputArgument;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * @Author tianyi
 * @Description // todo
 * @Date 2023 - 11 - 13
 **/
@DgsComponent
public class UserdataFetcher {
    public List<User> users = new ArrayList<>();
    @DgsMutation
    public User createUser(@InputArgument(name = "userInput") UserInput input){
        User user = new User();
        user.setId(UUID.randomUUID().toString());
        user.setPassword(input.getPassword());
        user.setEmail(input.getEmail());
        users.add(user);
        return user;
    }

    @DgsQuery
    public List<User> users (){
        return users;
    }
}
